package com.shelpe.services.sinbadgateway.utils;

import java.util.Date;

import javax.persistence.AttributeConverter;

public abstract class EntityUtils {

	
	public static class Day2IntConverter  implements AttributeConverter<Date, Integer>{

		@Override
		public Integer convertToDatabaseColumn(Date attribute) {
			return (int) (attribute.getTime() / 1000);
		}

		@Override
		public Date convertToEntityAttribute(Integer dbData) {
			long ts = dbData.intValue();
			return new Date(ts * 1000);
		}
		
	}
}
